home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QRZ! Ham Radio 8
/
QRZ Ham Radio Callsign Database - Volume 8.iso
/
pc
/
files
/
p_msys
/
msysb116.exe
/
SCAN757.ASM
< prev
next >
Wrap
Assembly Source File
|
1993-11-26
|
8KB
|
257 lines
; scan757.asm
; Here is sample source for a Scan TSR to be used with the MSYS
; Pactor scan command
; This example is for the Yeasu FT-757GXII. It may work for other
; Yeaus HF radios without modification. The FT-757 requires
; the following command format:
; pp pp pp pp cc
; where pp are 4 parameter bytes and cc is the operation
; to perform.
;
; For command 0A hex, the frequency is given in 4 bytes, using
; BCD (binary coded decimal) with the least significant byte
; first. The frequency is expressed in tens of Hz. Thus, for a frequency
; of 14,123.450 KHz, the four bytes would be
; 45 23 41 01
;
; The complete set of 5 bytes used to set a frequency of 7.021 MHz
; would be (in hex):
; 00 21 70 00 0A
; to produce the executable for this program, use the following
;
; asm scan757.asm {tasm or masm may be used}
; link scan757; {tlink may be used}
; exe2bin scan757 {makes .com file out of .exe file}
code segment
assume cs:code,ds:code
main proc far
org 0
segorg equ $
org 100h
start: jmp install
port dw 0 ;control uart base address
ten dw 10 ;divisor
thousand dw 1000
freq db 'freq' ;frequency in BCD, LSB first
db 0Ah
temp db 'hhhkkkmm0' ;work space build freq
savequot dw 0
;debug db 'xx $'
putser proc near
; send char in AL
push dx
push ax
mov dx,port
add dx,5 ;line status register
wait1: in al,dx
and al,20h ;check transmit holding reg
jz wait1 ;not ready yet
pop ax
mov dx,port
out dx,al ;send char to serial port
; The following commented out lines were used for debugging. They
; displayed each byte sent to the radio in hex.
; push ax
; push bx
; push cx
; push dx
; mov ah,al
; mov cl,4
; shr al,cl
; add al,'0'
; cmp al,'9'
; jle q1
; add al,7
;q1:
; mov debug,al
; and ah,15
; add ah,'0'
; cmp ah,'9'
; jle q2
; add ah,7
;q2:
; mov debug+1,ah
; mov dx,offset debug
; mov ah,9
; int 21h
; pop dx
; pop cx
; pop bx
; pop ax
pop dx
ret
putser endp
putserstr proc near
; sends string pointed to by bx, cx has number of bytes
push ax
push bx
push cx
psloop:
mov al, byte ptr [bx]
call putser
inc bx
dec cx
cmp cx,0
je putserstrexit
jmp psloop
putserstrexit:
pop cx
pop bx
pop ax
ret
putserstr endp
handler:
STI ; enable interrupts
; ; If we don't we will get overruns
; ; on the serial ports for the tnc's
push ds ; save some registers
push ax
push ax ; save ax a second time
mov ax,cs
mov ds,ax ; set up ds
pop ax ; get back the ax we were called with
;
; upon entry, dx has port address
; ax has high order part of frequency
; bx has low order part of frequency
mov port,dx
; The Yaesu manual says it wants 2 stop bits. Normally MSYS
; sets up the port for 1 stop bit. The next 5 instructions
; force the uart to 2 stop bits, 8 data bits
push ax ;save ax
add dx,3
mov al,7 ;2 stop, 8 data, no parity
out dx,al
pop ax ;restore ax
; div divides DX:AX giving quot in AX, rem in DX
mov dx,ax
mov ax,bx
; We have a bit of a problem in that the DIV instruction
; requires that the quotient will fit in a 16 bit register.
; But a frequency like 14.350, which is 14350000 in the
; long (32 bit) variable and when divided by 10 the
; quotient won't fit in 16 bits (AX).
;
; So here is what we will do...
; First divide the original frequency by 1000. This will
; give a quotient <= 30000 which will fit.
; The remainder from this division will be run thru the
; divide by 10 to get the digits loop three times.
; Then we take the quotient and use the same instructions
; to do the other 5 required digits
div thousand ;rem in dx, quot in ax
mov savequot,ax
mov ax,dx ;set up for divide
sub dx,dx
mov cx,3 ;number of digits
mov bx,offset temp ;place for first
dloop1:
div ten
add dl,'0' ;convert to ascii
mov byte ptr [bx],dl
sub dx,dx
inc bx
dec cx
cmp cx,0
jne dloop1
mov ax,savequot
sub dx,dx
mov cx,5
dloop2:
div ten
add dl,'0' ;convert to ascii
mov byte ptr [bx],dl
sub dx,dx
inc bx
dec cx
cmp cx,0
jne dloop2
; We now have 8 ascii bytes at temp, lsb first that is the freq
; We need to pack them into bcd, putting them at label freq
mov ah,temp+2
and ah,0Fh ;convert to bcd
mov cl,4
shl ah,cl ;shift left 4
mov al,temp+1
and al,0Fh
add ah,al
mov freq,ah
mov ah,temp+4
and ah,0Fh ;convert to bcd
shl ah,cl ;shift left 4
mov al,temp+3
and al,0Fh
add ah,al
mov freq+1,ah
mov ah,temp+6
and ah,0Fh ;convert to bcd
shl ah,cl ;shift left 4
mov al,temp+5
and al,0Fh
add ah,al
mov freq+2,ah
mov ah,temp+8
and ah,0Fh ;convert to bcd
shl ah,cl ;shift left 4
mov al,temp+7
and al,0Fh
add ah,al
mov freq+3,ah
mov cx,5
mov bx,offset freq
call putserstr
pop ax
pop ds
iret
main endp
install:
mov dx,offset msg1
mov ah,9
int 21h
mov dx,offset handler
mov al,0D4h
mov ah,25h
int 21h
mov dx,(offset install - segorg +15) shr 4
mov ah,31h
int 21h
msg1 db 'Scan TSR loaded for Yeasu FT-757GXII using Int D4',13,10,'$'
code ends
end start